package org.szy.plugin.gen.service.impl;

import cn.hutool.core.util.StrUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import org.noear.solon.annotation.ProxyComponent;
import org.szy.core.common.page.QueryPage;
import org.szy.core.common.service.impl.BaseServiceImpl;
import org.szy.plugin.gen.entity.GenConfig;
import org.szy.plugin.gen.mapper.GenConfigMapper;
import org.szy.plugin.gen.param.GenConfigQueryParam;
import org.szy.plugin.gen.service.GenConfigService;

import java.io.Serializable;
import java.util.List;

import static org.szy.plugin.gen.entity.table.GenConfigTableDef.GEN_CONFIG;

/**
 * 生成配置 服务层实现。
 *
 * @author sunzhiyang
 * @since 2023-06-14
 */
@ProxyComponent
public class GenConfigServiceImpl extends BaseServiceImpl<GenConfigMapper, GenConfig> implements GenConfigService {

    @Override
    public QueryWrapper qwByQuery(GenConfigQueryParam param) {
        QueryWrapper qw = new QueryWrapper();
        if (StrUtil.isNotEmpty(param.getBasicId())) qw.and(GEN_CONFIG.BASIC_ID.eq(param.getBasicId()));
        return qw;
    }

    @Override
    public Page<GenConfig> page(QueryPage<GenConfig> page, GenConfigQueryParam param) {
        QueryWrapper qw = qwByQuery(param);
        return this.page(page, qw);
    }

    @Override
    public boolean editBatch(List<GenConfig> genConfigList) {
        return this.updateBatch(genConfigList);
    }

    @Override
    public boolean removeByBasicId(Serializable basicId) {
        return remove(GEN_CONFIG.BASIC_ID.eq(basicId));
    }
}
